﻿@{
    ViewBag.Title = "角色列表页";
}
@section scripts
{
    <script type="text/javascript">
        $(function () {
            $("#editWindow").window('close');  // close a window
            $("#tbList").datagrid({
                width: 'auto',
                height: 300,
                striped: true,
                fitColumns: true,
                singleSelect: true,
                url: '/Admin/Role/GetRoleList',
                queryParams: {},
                loadMsg: '数据加载中请稍后……',
                pagination: true,
                rownumbers: true,
                pageSize: 5,
                pageList: [5, 10, 20],
                columns: [[
                    { field: 'rId', title: 'ID', width: 100 },
                    { field: 'rName', title: '角色名称', width: 100 },
                    { field: 'rDepName', title: '部门名称', width: 100 },
                    { field: 'rRemark', title: '备注', width: 100 }
                ]],
                toolbar: [
                    {
                        iconCls: 'icon-add',
                        handler: function () {
                            //add function
                            $('#editWindow').window('open');  // open a window
                            $("#editView").load("/admin/Role/Add");
                        }
                    }, '-', {
                        iconCls: 'icon-edit',
                        handler: function () {
                            //edit function
                            var selectRow = $("#tbList").datagrid("getSelected");
                            if (selectRow == null) {
                                $.messager.alert('警告', "请选择一行!");
                            } else {
                                $('#editWindow').window('open');  // open a window
                                $("#editView").load("/admin/Role/Edit/" + selectRow["rId"]);
                            }
                        }
                    }, '-', {
                        iconCls: 'icon-remove',
                        handler: function () {
                            //delete function
                            var selectRow = $("#tbList").datagrid("getSelected");
                            if (selectRow == null) {
                                $.messager.alert('警告', "请选择一行!");
                            } else {
                                $.post("/Admin/Role/Delete/" + selectRow["rId"], function (data) {
                                    $.ProcessMessage(data, function () {
                                        $("#tbList").datagrid("reload");
                                        $.messager.show({
                                            title: '提示',
                                            msg: '删除成功',
                                            timeout: 3000,
                                            showType: 'slide'
                                        });
                                    });
                                });
                            }
                        }
                    }, '-',{
                        iconCls: 'icon-reload',
                        handler: function () {
                            $('#tbList').datagrid('reload');
                        }
                    }
                ]

            });

            //initModifyForm();
        })
    </script>

}

<table id="tbList" style="height: 100%;width: 100%"></table>
<div id="editWindow" class="easyui-window" title="My Window" style="width:600px;height:400px"
     data-options="iconCls:'icon-save',modal:true">
    <div id="editView"></div>
</div>  